#include <base.h>
#include <debug.h>
#include "scheme.h"

void schemeCompiledFunction(void)
{
	DEBUG_ENTER("") ;

/* this is nasty, but so is using gcc's extension. i am disgusted to write this. */
#include "runtime.c"
#include "supportcode.c"

	pushDummyFrame(&&exit_1337) ;
	FUNCTION_ENTER("\t********** NEW SCHEME COMMAND: (binary-add 2 3) **********") ;
	DEBUG_TRACE("start: app tp: (binary-add 2 3)") ;
	/* Start of Pushing args */
	machine.reg[RES] = makeSchemeInt(3) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	machine.reg[RES] = makeSchemeInt(2) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	/* End of Pushing args */
	DEBUG_TRACE("start: var free: binary-add") ;
	machine.reg[RES] = getSymbol("binary-add") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: binary-add") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 2 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	machine.stack[machine.fp+1] = machine.stack[machine.sp+0] ;
	machine.stack[machine.fp+2] = machine.stack[machine.sp+1] ;
	/* End of overwriting old frame */
	machine.sp = machine.fp +3 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 2, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: (binary-add 2 3)") ;
	FUNCTION_EXIT("\t********** END OF SCHEME COMMAND **********") ;
exit_1337:
	POSTPROCESS(machine.reg[RES]) ;
	pushDummyFrame(&&exit_1338) ;
	FUNCTION_ENTER("\t********** NEW SCHEME COMMAND: ((lambda () (binary-add 2 3))) **********") ;
	DEBUG_TRACE("start: app tp: ((lambda () (binary-add 2 3)))") ;
	/* Start of Pushing args */
	/* End of Pushing args */
	DEBUG_TRACE("start: lambda: (lambda () (binary-add 2 3))") ;
	push((void*)machine.reg[1]) ;
	push((void*)machine.reg[2]) ;
	machine.reg[1] = makeLocalEnv (STACK_ARGS(), STACK_ARGC()) ;
	machine.reg[2] = extendEnv ((Environment)STACK_ENV(), machine.reg[1]) ;
	machine.reg[RES] = makeSchemeClosure (machine.reg[2], &&Closure_Code_1339 ) ;
	machine.reg[2] = pop() ;
	machine.reg[1] = pop() ;
	goto Continue_1340;
	Closure_Code_1339:
	FUNCTION_ENTER("(lambda () (binary-add 2 3))");
	RUNTIME_ASSERT(STACK_ARGC() == 0) ;
	DEBUG_TRACE("start: app tp: (binary-add 2 3)") ;
	/* Start of Pushing args */
	machine.reg[RES] = makeSchemeInt(3) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	machine.reg[RES] = makeSchemeInt(2) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	/* End of Pushing args */
	DEBUG_TRACE("start: var free: binary-add") ;
	machine.reg[RES] = getSymbol("binary-add") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: binary-add") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 2 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	machine.stack[machine.fp+1] = machine.stack[machine.sp+0] ;
	machine.stack[machine.fp+2] = machine.stack[machine.sp+1] ;
	/* End of overwriting old frame */
	machine.sp = machine.fp +3 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 2, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: (binary-add 2 3)") ;
	FUNCTION_EXIT ("(lambda () (binary-add 2 3))");
	Continue_1340:
	DEBUG_TRACE("end: lambda: (lambda () (binary-add 2 3))") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 0 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	/* End of overwriting old frame */
	machine.sp = machine.fp +1 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 0, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: ((lambda () (binary-add 2 3)))") ;
	FUNCTION_EXIT("\t********** END OF SCHEME COMMAND **********") ;
exit_1338:
	POSTPROCESS(machine.reg[RES]) ;
	pushDummyFrame(&&exit_1341) ;
	FUNCTION_ENTER("\t********** NEW SCHEME COMMAND: ((lambda () 1)) **********") ;
	DEBUG_TRACE("start: app tp: ((lambda () 1))") ;
	/* Start of Pushing args */
	/* End of Pushing args */
	DEBUG_TRACE("start: lambda: (lambda () 1)") ;
	push((void*)machine.reg[1]) ;
	push((void*)machine.reg[2]) ;
	machine.reg[1] = makeLocalEnv (STACK_ARGS(), STACK_ARGC()) ;
	machine.reg[2] = extendEnv ((Environment)STACK_ENV(), machine.reg[1]) ;
	machine.reg[RES] = makeSchemeClosure (machine.reg[2], &&Closure_Code_1342 ) ;
	machine.reg[2] = pop() ;
	machine.reg[1] = pop() ;
	goto Continue_1343;
	Closure_Code_1342:
	FUNCTION_ENTER("(lambda () 1)");
	RUNTIME_ASSERT(STACK_ARGC() == 0) ;
	machine.reg[RES] = makeSchemeInt(1) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	FUNCTION_EXIT ("(lambda () 1)");
	Continue_1343:
	DEBUG_TRACE("end: lambda: (lambda () 1)") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 0 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	/* End of overwriting old frame */
	machine.sp = machine.fp +1 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 0, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: ((lambda () 1))") ;
	FUNCTION_EXIT("\t********** END OF SCHEME COMMAND **********") ;
exit_1341:
	POSTPROCESS(machine.reg[RES]) ;
	pushDummyFrame(&&exit_1344) ;
	FUNCTION_ENTER("\t********** NEW SCHEME COMMAND: ((lambda (fact) (begin (set! fact (box fact)) (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))) ((lambda () ((vector-ref fact 0) 6))))) #f) **********") ;
	DEBUG_TRACE("start: app tp: ((lambda (fact) (begin (set! fact (box fact)) (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))) ((lambda () ((vector-ref fact 0) 6))))) #f)") ;
	/* Start of Pushing args */
	machine.reg[RES] = makeSchemeBool(FALSE);
	push((void*)machine.reg[RES]) ;
	/* End of Pushing args */
	DEBUG_TRACE("start: lambda: (lambda (fact) (begin (set! fact (box fact)) (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))) ((lambda () ((vector-ref fact 0) 6)))))") ;
	push((void*)machine.reg[1]) ;
	push((void*)machine.reg[2]) ;
	machine.reg[1] = makeLocalEnv (STACK_ARGS(), STACK_ARGC()) ;
	machine.reg[2] = extendEnv ((Environment)STACK_ENV(), machine.reg[1]) ;
	machine.reg[RES] = makeSchemeClosure (machine.reg[2], &&Closure_Code_1358 ) ;
	machine.reg[2] = pop() ;
	machine.reg[1] = pop() ;
	goto Continue_1359;
	Closure_Code_1358:
	FUNCTION_ENTER("(lambda (fact) (begin (set! fact (box fact)) (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))) ((lambda () ((vector-ref fact 0) 6)))))");
	RUNTIME_ASSERT(STACK_ARGC() == 1) ;
	DEBUG_TRACE("start: sequence: (begin (set! fact (box fact)) (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))) ((lambda () ((vector-ref fact 0) 6))))") ;
	/* start new begin statement */
	DEBUG_TRACE("start: set: (set! fact (box fact))") ;
	DEBUG_TRACE("start: application: (box fact)") ;
	push((void*)machine.reg[1]) ; /* will be environment */
	push((void*)machine.reg[0]) ; /* will be code */
	/* calculating application's arguments */
	DEBUG_TRACE("start: var param: fact") ;
	machine.reg[RES] = STACK_ARGV(0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var param: fact") ;
	push((void*)machine.reg[RES]) ;
	/* calculating the closure */
	DEBUG_TRACE("start: var free: box") ;
	machine.reg[RES] = getSymbol("box") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: box") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	CALL(*machine.reg[0], 1, machine.reg[1], &&ret_from_app_1345) ;
	ret_from_app_1345:
	machine.reg[0] = pop() ; /* was code */
	machine.reg[1] = pop() ; /* was environment */
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: application: (box fact)") ;
	*(STACK_ARGS()-0) = machine.reg[RES] ;
	machine.reg[RES] = makeSchemeVoid() ;
	DEBUG_TRACE("end: set: (set! fact (box fact))") ;
	/* start new begin statement */
	DEBUG_TRACE("start: application: (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1))))))") ;
	push((void*)machine.reg[1]) ; /* will be environment */
	push((void*)machine.reg[0]) ; /* will be code */
	/* calculating application's arguments */
	DEBUG_TRACE("start: lambda: (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))") ;
	push((void*)machine.reg[1]) ;
	push((void*)machine.reg[2]) ;
	machine.reg[1] = makeLocalEnv (STACK_ARGS(), STACK_ARGC()) ;
	machine.reg[2] = extendEnv ((Environment)STACK_ENV(), machine.reg[1]) ;
	machine.reg[RES] = makeSchemeClosure (machine.reg[2], &&Closure_Code_1352 ) ;
	machine.reg[2] = pop() ;
	machine.reg[1] = pop() ;
	goto Continue_1353;
	Closure_Code_1352:
	FUNCTION_ENTER("(lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))");
	RUNTIME_ASSERT(STACK_ARGC() == 1) ;
	DEBUG_TRACE("start: if: (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1))))") ;

	DEBUG_TRACE("start: application: (zero\? n)") ;
	push((void*)machine.reg[1]) ; /* will be environment */
	push((void*)machine.reg[0]) ; /* will be code */
	/* calculating application's arguments */
	DEBUG_TRACE("start: var param: n") ;
	machine.reg[RES] = STACK_ARGV(0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var param: n") ;
	push((void*)machine.reg[RES]) ;
	/* calculating the closure */
	DEBUG_TRACE("start: var free: zero\?") ;
	machine.reg[RES] = getSymbol("zero?") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: zero\?") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	CALL(*machine.reg[0], 1, machine.reg[1], &&ret_from_app_1346) ;
	ret_from_app_1346:
	machine.reg[0] = pop() ; /* was code */
	machine.reg[1] = pop() ; /* was environment */
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: application: (zero\? n)") ;
	if (sobIsFalse(machine.reg[RES])) goto If_Else_1350;
	DEBUG_NOTICE("branch taken");
	machine.reg[RES] = makeSchemeInt(1) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	goto If_Done_1351;
	If_Else_1350:
	DEBUG_NOTICE("branch not taken");
	DEBUG_TRACE("start: app tp: (* n ((vector-ref fact 0) (- n 1)))") ;
	/* Start of Pushing args */
	DEBUG_TRACE("start: application: ((vector-ref fact 0) (- n 1))") ;
	push((void*)machine.reg[1]) ; /* will be environment */
	push((void*)machine.reg[0]) ; /* will be code */
	/* calculating application's arguments */
	DEBUG_TRACE("start: application: (- n 1)") ;
	push((void*)machine.reg[1]) ; /* will be environment */
	push((void*)machine.reg[0]) ; /* will be code */
	/* calculating application's arguments */
	machine.reg[RES] = makeSchemeInt(1) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	DEBUG_TRACE("start: var param: n") ;
	machine.reg[RES] = STACK_ARGV(0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var param: n") ;
	push((void*)machine.reg[RES]) ;
	/* calculating the closure */
	DEBUG_TRACE("start: var free: -") ;
	machine.reg[RES] = getSymbol("-") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: -") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	CALL(*machine.reg[0], 2, machine.reg[1], &&ret_from_app_1347) ;
	ret_from_app_1347:
	machine.reg[0] = pop() ; /* was code */
	machine.reg[1] = pop() ; /* was environment */
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: application: (- n 1)") ;
	push((void*)machine.reg[RES]) ;
	/* calculating the closure */
	DEBUG_TRACE("start: application: (vector-ref fact 0)") ;
	push((void*)machine.reg[1]) ; /* will be environment */
	push((void*)machine.reg[0]) ; /* will be code */
	/* calculating application's arguments */
	machine.reg[RES] = makeSchemeInt(0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	DEBUG_TRACE("start: var bound: fact") ;
	machine.reg[RES] = getBoundVar (STACK_ENV(), 0, 0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var bound: fact") ;
	push((void*)machine.reg[RES]) ;
	/* calculating the closure */
	DEBUG_TRACE("start: var free: vector-ref") ;
	machine.reg[RES] = getSymbol("vector-ref") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: vector-ref") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	CALL(*machine.reg[0], 2, machine.reg[1], &&ret_from_app_1349) ;
	ret_from_app_1349:
	machine.reg[0] = pop() ; /* was code */
	machine.reg[1] = pop() ; /* was environment */
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: application: (vector-ref fact 0)") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	CALL(*machine.reg[0], 1, machine.reg[1], &&ret_from_app_1348) ;
	ret_from_app_1348:
	machine.reg[0] = pop() ; /* was code */
	machine.reg[1] = pop() ; /* was environment */
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: application: ((vector-ref fact 0) (- n 1))") ;
	push((void*)machine.reg[RES]) ;
	DEBUG_TRACE("start: var param: n") ;
	machine.reg[RES] = STACK_ARGV(0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var param: n") ;
	push((void*)machine.reg[RES]) ;
	/* End of Pushing args */
	DEBUG_TRACE("start: var free: *") ;
	machine.reg[RES] = getSymbol("*") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: *") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 2 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	machine.stack[machine.fp+1] = machine.stack[machine.sp+0] ;
	machine.stack[machine.fp+2] = machine.stack[machine.sp+1] ;
	/* End of overwriting old frame */
	machine.sp = machine.fp +3 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 2, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: (* n ((vector-ref fact 0) (- n 1)))") ;
	If_Done_1351:

	DEBUG_TRACE("end: if: (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1))))") ;
	FUNCTION_EXIT ("(lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))");
	Continue_1353:
	DEBUG_TRACE("end: lambda: (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))") ;
	push((void*)machine.reg[RES]) ;
	machine.reg[RES] = makeSchemeInt(0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	DEBUG_TRACE("start: var param: fact") ;
	machine.reg[RES] = STACK_ARGV(0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var param: fact") ;
	push((void*)machine.reg[RES]) ;
	/* calculating the closure */
	DEBUG_TRACE("start: var free: vector-set!") ;
	machine.reg[RES] = getSymbol("vector-set!") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: vector-set!") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	CALL(*machine.reg[0], 3, machine.reg[1], &&ret_from_app_1354) ;
	ret_from_app_1354:
	machine.reg[0] = pop() ; /* was code */
	machine.reg[1] = pop() ; /* was environment */
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: application: (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1))))))") ;
	/* start new begin statement */
	DEBUG_TRACE("start: app tp: ((lambda () ((vector-ref fact 0) 6)))") ;
	/* Start of Pushing args */
	/* End of Pushing args */
	DEBUG_TRACE("start: lambda: (lambda () ((vector-ref fact 0) 6))") ;
	push((void*)machine.reg[1]) ;
	push((void*)machine.reg[2]) ;
	machine.reg[1] = makeLocalEnv (STACK_ARGS(), STACK_ARGC()) ;
	machine.reg[2] = extendEnv ((Environment)STACK_ENV(), machine.reg[1]) ;
	machine.reg[RES] = makeSchemeClosure (machine.reg[2], &&Closure_Code_1356 ) ;
	machine.reg[2] = pop() ;
	machine.reg[1] = pop() ;
	goto Continue_1357;
	Closure_Code_1356:
	FUNCTION_ENTER("(lambda () ((vector-ref fact 0) 6))");
	RUNTIME_ASSERT(STACK_ARGC() == 0) ;
	DEBUG_TRACE("start: app tp: ((vector-ref fact 0) 6)") ;
	/* Start of Pushing args */
	machine.reg[RES] = makeSchemeInt(6) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	/* End of Pushing args */
	DEBUG_TRACE("start: application: (vector-ref fact 0)") ;
	push((void*)machine.reg[1]) ; /* will be environment */
	push((void*)machine.reg[0]) ; /* will be code */
	/* calculating application's arguments */
	machine.reg[RES] = makeSchemeInt(0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	DEBUG_TRACE("start: var bound: fact") ;
	machine.reg[RES] = getBoundVar (STACK_ENV(), 0, 0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var bound: fact") ;
	push((void*)machine.reg[RES]) ;
	/* calculating the closure */
	DEBUG_TRACE("start: var free: vector-ref") ;
	machine.reg[RES] = getSymbol("vector-ref") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: vector-ref") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	CALL(*machine.reg[0], 2, machine.reg[1], &&ret_from_app_1355) ;
	ret_from_app_1355:
	machine.reg[0] = pop() ; /* was code */
	machine.reg[1] = pop() ; /* was environment */
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: application: (vector-ref fact 0)") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 1 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	machine.stack[machine.fp+1] = machine.stack[machine.sp+0] ;
	/* End of overwriting old frame */
	machine.sp = machine.fp +2 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 1, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: ((vector-ref fact 0) 6)") ;
	FUNCTION_EXIT ("(lambda () ((vector-ref fact 0) 6))");
	Continue_1357:
	DEBUG_TRACE("end: lambda: (lambda () ((vector-ref fact 0) 6))") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 0 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	/* End of overwriting old frame */
	machine.sp = machine.fp +1 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 0, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: ((lambda () ((vector-ref fact 0) 6)))") ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: sequence: (begin (set! fact (box fact)) (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))) ((lambda () ((vector-ref fact 0) 6))))") ;
	FUNCTION_EXIT ("(lambda (fact) (begin (set! fact (box fact)) (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))) ((lambda () ((vector-ref fact 0) 6)))))");
	Continue_1359:
	DEBUG_TRACE("end: lambda: (lambda (fact) (begin (set! fact (box fact)) (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))) ((lambda () ((vector-ref fact 0) 6)))))") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 1 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	machine.stack[machine.fp+1] = machine.stack[machine.sp+0] ;
	/* End of overwriting old frame */
	machine.sp = machine.fp +2 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 1, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: ((lambda (fact) (begin (set! fact (box fact)) (vector-set! fact 0 (lambda (n) (if (zero\? n) 1 (* n ((vector-ref fact 0) (- n 1)))))) ((lambda () ((vector-ref fact 0) 6))))) #f)") ;
	FUNCTION_EXIT("\t********** END OF SCHEME COMMAND **********") ;
exit_1344:
	POSTPROCESS(machine.reg[RES]) ;
	pushDummyFrame(&&exit_1360) ;
	FUNCTION_ENTER("\t********** NEW SCHEME COMMAND: ((((lambda () (lambda (x y) (lambda (c d) (binary-add x d))))) 3 4) 1 2) **********") ;
	DEBUG_TRACE("start: app tp: ((((lambda () (lambda (x y) (lambda (c d) (binary-add x d))))) 3 4) 1 2)") ;
	/* Start of Pushing args */
	machine.reg[RES] = makeSchemeInt(2) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	machine.reg[RES] = makeSchemeInt(1) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	/* End of Pushing args */
	DEBUG_TRACE("start: application: (((lambda () (lambda (x y) (lambda (c d) (binary-add x d))))) 3 4)") ;
	push((void*)machine.reg[1]) ; /* will be environment */
	push((void*)machine.reg[0]) ; /* will be code */
	/* calculating application's arguments */
	machine.reg[RES] = makeSchemeInt(4) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	machine.reg[RES] = makeSchemeInt(3) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	push((void*)machine.reg[RES]) ;
	/* calculating the closure */
	DEBUG_TRACE("start: application: ((lambda () (lambda (x y) (lambda (c d) (binary-add x d)))))") ;
	push((void*)machine.reg[1]) ; /* will be environment */
	push((void*)machine.reg[0]) ; /* will be code */
	/* calculating application's arguments */
	/* calculating the closure */
	DEBUG_TRACE("start: lambda: (lambda () (lambda (x y) (lambda (c d) (binary-add x d))))") ;
	push((void*)machine.reg[1]) ;
	push((void*)machine.reg[2]) ;
	machine.reg[1] = makeLocalEnv (STACK_ARGS(), STACK_ARGC()) ;
	machine.reg[2] = extendEnv ((Environment)STACK_ENV(), machine.reg[1]) ;
	machine.reg[RES] = makeSchemeClosure (machine.reg[2], &&Closure_Code_1367 ) ;
	machine.reg[2] = pop() ;
	machine.reg[1] = pop() ;
	goto Continue_1368;
	Closure_Code_1367:
	FUNCTION_ENTER("(lambda () (lambda (x y) (lambda (c d) (binary-add x d))))");
	RUNTIME_ASSERT(STACK_ARGC() == 0) ;
	DEBUG_TRACE("start: lambda: (lambda (x y) (lambda (c d) (binary-add x d)))") ;
	push((void*)machine.reg[1]) ;
	push((void*)machine.reg[2]) ;
	machine.reg[1] = makeLocalEnv (STACK_ARGS(), STACK_ARGC()) ;
	machine.reg[2] = extendEnv ((Environment)STACK_ENV(), machine.reg[1]) ;
	machine.reg[RES] = makeSchemeClosure (machine.reg[2], &&Closure_Code_1365 ) ;
	machine.reg[2] = pop() ;
	machine.reg[1] = pop() ;
	goto Continue_1366;
	Closure_Code_1365:
	FUNCTION_ENTER("(lambda (x y) (lambda (c d) (binary-add x d)))");
	RUNTIME_ASSERT(STACK_ARGC() == 2) ;
	DEBUG_TRACE("start: lambda: (lambda (c d) (binary-add x d))") ;
	push((void*)machine.reg[1]) ;
	push((void*)machine.reg[2]) ;
	machine.reg[1] = makeLocalEnv (STACK_ARGS(), STACK_ARGC()) ;
	machine.reg[2] = extendEnv ((Environment)STACK_ENV(), machine.reg[1]) ;
	machine.reg[RES] = makeSchemeClosure (machine.reg[2], &&Closure_Code_1363 ) ;
	machine.reg[2] = pop() ;
	machine.reg[1] = pop() ;
	goto Continue_1364;
	Closure_Code_1363:
	FUNCTION_ENTER("(lambda (c d) (binary-add x d))");
	RUNTIME_ASSERT(STACK_ARGC() == 2) ;
	DEBUG_TRACE("start: app tp: (binary-add x d)") ;
	/* Start of Pushing args */
	DEBUG_TRACE("start: var param: d") ;
	machine.reg[RES] = STACK_ARGV(1) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var param: d") ;
	push((void*)machine.reg[RES]) ;
	DEBUG_TRACE("start: var bound: x") ;
	machine.reg[RES] = getBoundVar (STACK_ENV(), 0, 0) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var bound: x") ;
	push((void*)machine.reg[RES]) ;
	/* End of Pushing args */
	DEBUG_TRACE("start: var free: binary-add") ;
	machine.reg[RES] = getSymbol("binary-add") ;
	RUNTIME_ASSERT(SYMBOL_ENTRY(machine.reg[RES])->isDefined) ;
	machine.reg[RES] = SYMBOL_ENTRY_OBJ(machine.reg[RES]) ;
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: var free: binary-add") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 2 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	machine.stack[machine.fp+1] = machine.stack[machine.sp+0] ;
	machine.stack[machine.fp+2] = machine.stack[machine.sp+1] ;
	/* End of overwriting old frame */
	machine.sp = machine.fp +3 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 2, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: (binary-add x d)") ;
	FUNCTION_EXIT ("(lambda (c d) (binary-add x d))");
	Continue_1364:
	DEBUG_TRACE("end: lambda: (lambda (c d) (binary-add x d))") ;
	FUNCTION_EXIT ("(lambda (x y) (lambda (c d) (binary-add x d)))");
	Continue_1366:
	DEBUG_TRACE("end: lambda: (lambda (x y) (lambda (c d) (binary-add x d)))") ;
	FUNCTION_EXIT ("(lambda () (lambda (x y) (lambda (c d) (binary-add x d))))");
	Continue_1368:
	DEBUG_TRACE("end: lambda: (lambda () (lambda (x y) (lambda (c d) (binary-add x d))))") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	CALL(*machine.reg[0], 0, machine.reg[1], &&ret_from_app_1362) ;
	ret_from_app_1362:
	machine.reg[0] = pop() ; /* was code */
	machine.reg[1] = pop() ; /* was environment */
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: application: ((lambda () (lambda (x y) (lambda (c d) (binary-add x d)))))") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	CALL(*machine.reg[0], 2, machine.reg[1], &&ret_from_app_1361) ;
	ret_from_app_1361:
	machine.reg[0] = pop() ; /* was code */
	machine.reg[1] = pop() ; /* was environment */
	DEBUG_CASUAL("result = %p -- %s", machine.reg[RES], sobToString(Sob(machine.reg[RES]))) ;
	DEBUG_TRACE("end: application: (((lambda () (lambda (x y) (lambda (c d) (binary-add x d))))) 3 4)") ;
	RUNTIME_ASSERT(sobIsClosure(machine.reg[RES])) ;
	machine.reg[1] = SOB_CLOSURE_ENV(machine.reg[RES]) ;
	machine.reg[0] = SOB_CLOSURE_CODE(machine.reg[RES]) ;
	machine.reg[3] = (void*)STACK_OLD_FP() ;
	machine.reg[2] = STACK_RET_ADDRESS() ;
	machine.sp -= 2 ; /* Puts Sp the begining of items to copy (function arguments) */
	machine.fp -= 5+STACK_ARGC() ; /* Bottom of current frame which is also where the base for our overwritten one (5 == (fp+ret+env+argc)+ argv) */
	/* Start of overwriting old frame */
	machine.stack[machine.fp+1] = machine.stack[machine.sp+0] ;
	machine.stack[machine.fp+2] = machine.stack[machine.sp+1] ;
	/* End of overwriting old frame */
	machine.sp = machine.fp +3 ; /* sets sp to top of overwritten frame */
	machine.fp = (int)machine.reg[3] ;
	CALL(*machine.reg[0], 2, machine.reg[1], machine.reg[2]) ;
	DEBUG_TRACE("end: app tp: ((((lambda () (lambda (x y) (lambda (c d) (binary-add x d))))) 3 4) 1 2)") ;
	FUNCTION_EXIT("\t********** END OF SCHEME COMMAND **********") ;
exit_1360:

	DEBUG_EXIT("") ;
	return ;
}

